package P1000;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-10-10 14:07
 */
public class P1036_选数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] nums = new int[n];
        for(int i=0;i<n;++i) nums[i] = scanner.nextInt();
        scanner.close();
        invoke(k,nums);
    }

    static int res = 0;

    private static void invoke(int k, int[] nums) {
        Arrays.sort(nums);
        dfs(0,0,k,0,nums);
        System.out.println(res);
    }

    private static void dfs(int index,int now,int k, int sum,int[] nums) {
        if(now == k){
            if(isPrime(sum)) ++res;
            return ;
        }
        for(int i=index;i<nums.length;++i){
            sum += nums[i];
            dfs(i+1,now+1,k,sum,nums);
            sum -= nums[i];
        }
    }

    private static boolean isPrime(int n){
        int div = n/2;
        for(int i=2;i<div;++i){
            if(n%i == 0) return false;
        }
        return true;
    }
}
